package 华为;

import java.util.Scanner;

// https://blog.csdn.net/Albert_J/article/details/117999745?spm=1001.2014.3001.5501

public class Huawei3 {
    private static int cnt;
    private static final int SIZE = 20;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[][] nums = new int[SIZE][SIZE];
        for (int i = 0; i < SIZE; i++) {
            for (int j = 0; j < SIZE; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }
        int maxWhite = 0;
        int maxBlack = 0;
        for (int i = 0; i < SIZE; i++) {
            for (int j = 0; j < SIZE; j++) {
                if (nums[i][j] == 1) {
                    cnt = 0;
                    //白子
                    traceBack(i, j, 1, nums);
                    maxWhite = Math.max(maxWhite, cnt);
                }
                if (nums[i][j] == 2) {
                    cnt = 0;
                    //黑子
                    traceBack(i, j, 2, nums);
                    maxBlack = Math.max(maxBlack, cnt);
                }
            }
        }
        System.out.println(maxWhite);
        System.out.println(maxBlack);
        if (maxWhite > maxBlack) {
            System.out.println("white");
        } else if (maxBlack == maxWhite) {
            System.out.println("equal");
        } else {
            System.out.println("black");
        }
    }

    private static void traceBack(int i, int j, int target, int[][] nums) {
        if (i < 0 || i >= SIZE) return;
        if (j < 0 || j >= SIZE) return;
        if (nums[i][j] == target) {
            cnt++;
            nums[i][j] = 0;
            traceBack(i + 1, j, target, nums);
            traceBack(i - 1, j, target, nums);
            traceBack(i, j - 1, target, nums);
            traceBack(i, j + 1, target, nums);
        }
    }
}
